package com.example.park2212.house

import androidx.lifecycle.MutableLiveData


import com.example.lib_base.entity.HouseBean
import com.example.lib_base.entity.HouseBeanItem
import com.example.lib_base.mvvm.BaseViewModel
import com.example.lib_base.net.ApiService
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class HoursViewModel @Inject constructor(val apiService: ApiService):BaseViewModel() {

    val houseSuccess = MutableLiveData<HouseBean>()
    fun house(){
        httpRequest({
            apiService.getHouse()
        },houseSuccess::postValue)
    }

    fun getHourseById(regionId:Int){
        httpRequest({
            apiService.getHourseById(regionId)
        },houseSuccess::postValue)
    }

    val rentHouseSuccess = MutableLiveData<HouseBeanItem>()
    fun rentHouse(id:Int,rentDate:String){
        httpRequest({
            apiService.rentHouse(id,rentDate)
        },rentHouseSuccess::postValue)
    }


    fun unrentHouse(id:Int){
        httpRequest({
            apiService.unrentHouse(id)
        },rentHouseSuccess::postValue)
    }


}